package com.lepu.app.usercenter.bean;

import android.content.Context;

import com.app.application.MyApplication;
import com.app.config.UserConfig;
import com.app.utils.Const;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class LoginInfo {

	public String UserID;//int
	public String LoginToken;
	
	public String NickName;
	public String MobilePhone;
	public String Avatar;//用户头像
	public String BabyBirthDate;//宝宝出生日期
	public String BabyName;
	public String DueDate;//预产期
	
	public String BirthWay;//宝宝生产方式	1：顺产2：剖腹产
	public String BabyGender;//宝宝性别	0：未知；1：男；2：女；3：龙凤胎
	public String BabyBirthed;//0：未出生 	1：已出生
	public String IsPremature;//0：非早产	1：早产
	public String HasSecurityQuestion;//0：未设置	1：已设置
	//grow new 
	public String AlbumName;
	public String AlbumCoverURL;
	public String AlbumMusicID;
	
	//护生堂商场字段
	public String HSTAccessToken;
	public String HSTAccessTokenExpireTime;
	
	public static LoginInfo parseLoginInfo(String value) {
		
		Gson gson = new Gson();
		LoginInfo model = gson.fromJson(value,
				new TypeToken<LoginInfo>() {
				}.getType());
		return model;
	}
	
	public static void saveLoginInfo(Context context,LoginInfo loginInfo)
	{
		Gson gson = new Gson();
		String value = gson.toJson(loginInfo);

		LoginInfo newLoginInfo = LoginInfo.parseLoginInfo(value);
		MyApplication.getInstance().setLoginInfo(newLoginInfo);
		
		UserConfig.setConfig(context, Const.CONFIG_APP_LOGIN_INFO, value);
	}
}
